//商品管理模块的接口
import request from '@/utils/request'
import type {
  GoodsRecords,
  Status,
//枚举地址
} from './type'
import { RoleResponseData } from '@/api/acl/role/type'

enum API {
  //获取所有商品
  ALLGOODS_URL = '/goods/getSeckillGoodsAll',
  //获取商品根据状态
  LISTGOODS_URL = '/goods/getSeckillGoodsByStatus',
  //添加一个新商品
  ADDGOODS_URL = '/goods/saveSeckillGoods',
  //获取商品详情
  GETGOODSBYID_URL = '/goods/getSeckillGoodsId',
  //修改状态
  UPDATESTATUS_URL = '/goods/updateStatus',
  //删除商品
  DELGOODS_URL = '/goods/delGoodsById',
  //根据活动id获取商品
  GETSECKILLGOODSBYACTIVITYID_URL = '/goods/getSeckillGoodsByActivityId',
}

//获取所有商品
export const reqGoodsInfoAll = () => {
  return request.post<any, any>(API.ALLGOODS_URL)
}
//根据状态获取商品
export const reqGoodsInfoList = (status: string) =>
  request.get<any, any>(
    API.LISTGOODS_URL + `/?status=${status}`,
  )
//删除商品
export const reqDelGoods = (id: number) =>
  request.get<any, any>(
    API.DELGOODS_URL + `/?id=${id}`,
  )
//获取商品详情
export const reqGetGoodsById = (id: number) =>
  request.get<any, any>(
    API.GETGOODSBYID_URL + `/?id=${id}`,
  )
// 增加商品
export const reqAddGoods = (data: GoodsRecords) => {
  return request.post<any, any>(API.ADDGOODS_URL, data)
}
// 修改商品状态
export const reqUpdateStatus = (id: number, status: string) =>
  request.get<any, any>(
    API.UPDATESTATUS_URL + `/?status=${status}&id=${id}`,
  )
// 根据活动id商品列表
export const reqGetGoodsByActivityId = (activityId: number) =>
  request.get<any, any>(
    API.GETSECKILLGOODSBYACTIVITYID_URL + `/?activityId=${activityId}`,
  )
